home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 51 / Amiga Format CD51 (2000-03-10)(Future Publishing)(GB)[!][issue 2000-04].iso / -in_the_mag- / banging_the_metal / qdos / qdos4amiga2 / romsrc / mdv / mdv_asm
Text File  |  2000-01-03  |  7KB  |  364 lines

  1. */beginfile MDV_asm
  2. ; --------------------------------------------------------------
  3. ; MDV_asm - dummy microdrive device driver for QDOS
  4. ;     - last modified 04/01/98
  5. ; --------------------------------------------------------------
  6.  
  7.     SECTION    MDV
  8.  
  9.     INCLUDE    '/INC/QDOS_inc'
  10.  
  11. mdd.name equ    'MDV0'
  12. mdd_end    equ    SV_LIO+CH_DRNAM+2+4
  13. md_end    equ    $20
  14.  
  15. ; --------------------------------------------------------------
  16. rom_base
  17.     dc.l    $4afb0001
  18.     dc.w    proc_tab-rom_base
  19.     dc.w    rom_init-rom_base
  20.     dc.b    0,30,'MDV dummy device driver v1.00',$a
  21.     dc.w    0
  22. ; --------------------------------------------------------------
  23. rom_init
  24.  
  25.     bra.l    md_init
  26.  
  27. ; --------------------------------------------------------------
  28. proc_tab
  29.     dc.w    8        ; 4 procedures
  30.  
  31.     dc.w    mdv_use-*
  32.     dc.b    7,'MDV_USE'
  33.     dc.w    prog_use-*
  34.     dc.b    8,'PROG_USE',0
  35.     dc.w    data_use-*
  36.     dc.b    8,'DATA_USE',0
  37.     dc.w    dest_use-*
  38.     dc.b    8,'DEST_USE',0
  39.     dc.w    spl_use-*
  40.     dc.b    7,'SPL_USE'
  41.     dc.w    0        ; end of procedures
  42.  
  43.     dc.w    3        ; 3 functions
  44.     dc.w    prog_d$-*
  45.     dc.b    6,'PROGD$',0
  46.     dc.w    data_d$-*
  47.     dc.b    6,'DATAD$',0
  48.     dc.w    dest_d$-*
  49.     dc.b    6,'DESTD$',0
  50.     dc.w    0        ; end of functions
  51.  
  52. ; --------------------------------------------------------------
  53. md_init
  54.     movem.l    a0/a3,-(sp)
  55.  
  56.     moveq    #mdd_end,d1
  57.     moveq    #MT.ALCHP,d0
  58.     moveq    #0,d2
  59.     trap    #1
  60.  
  61.     lea    md_poll(pc),a2
  62.     move.l    a2,SV_APOLL(a0)    ; !
  63.  
  64.     lea    SV_AIO(a0),a3
  65.     lea    md_io(pc),a2
  66.     move.l    a2,(a3)+     ; input/output... at $1c
  67.     lea    md_opn(pc),a2
  68.     move.l    a2,(a3)+     ; open... at $20
  69.     lea    md_clos(pc),a2
  70.     move.l    a2,(a3)+     ; close... at $24
  71.     lea    md_slave(pc),a2    ; slave
  72.     move.l    a2,(a3)+
  73.     addq.l    #8,a3        ; two spare
  74.     lea    md_format(pc),a2    ; format
  75.     move.l    a2,(a3)+
  76.     move.l    #md_end,(a3)+    ; length
  77.     move.w    #3,(a3)+
  78.     move.l    #mdd.name,(a3)+
  79.  
  80.     move.l    a0,a3
  81.  
  82. *     lea     SV_LPOLL(a3),a0     ; link into
  83. *     moveq     #MT.LPOLL,d0     ; polling list !
  84. *     trap     #1
  85.  
  86.     lea    SV_LIO(a3),a0    ; link into
  87.     moveq    #MT.LDD,d0    ; dd driver list
  88.     trap    #1
  89.  
  90.     moveq    #MT.INF,d0    ; find the system variables
  91.     trap    #1
  92.     lea    SV_PROGD(a0),a4    ; and set the pointers to
  93.                 ; the defaults
  94.  
  95.     moveq    #MT.ALCHP,d0    ; make space for defaults
  96.     moveq    #3*36,d1     ; ** 1.17 **
  97.     moveq    #0,d2
  98.     trap    #1
  99.  
  100. md_dflts
  101.     move.l    #$00050000+(mdd.name>>16),d1
  102.     move.l    #((mdd.name+1)<<16)+'_ ',d2
  103.     move.l    a0,(a4)+     ; program default MDV1_
  104.     move.l    d1,(a0)+
  105.     move.l    d2,(a0)
  106.     add.w    #32,a0
  107.     move.l    a0,(a4)+     ; data default MDV1_
  108.     move.l    d1,(a0)+
  109.     move.l    d2,(a0)
  110.     add.w    #1,(a0)        ; Data default now MDV2_
  111.     add.w    #32,a0
  112.     move.l    a0,(a4)+     ; spool default PAR
  113.     move.l    #$00030000+'PA',(a0)+
  114.     move.b    #'R',(a0)+
  115.  
  116.     movem.l    (sp)+,a0/a3
  117.     rts
  118.  
  119. ; --------------------------------------------------------------
  120. md_io:
  121. md_opn:
  122. md_clos:
  123. md_format:
  124.     moveq    #ERR.NF,d0    ; return 'not found' error
  125.     rts
  126.  
  127. ; --------------------------------------------------------------
  128. md_slave:
  129.     moveq    #ERR.OK,d0    ; return 'OK' error
  130.     rts
  131.  
  132. ; --------------------------------------------------------------
  133. md_poll:
  134.     rts            ; return immediately
  135.  
  136. ; --------------------------------------------------------------
  137. ;
  138. ;      BASIC extensions start here
  139. ;
  140. ; --------------------------------------------------------------
  141. prog_use
  142.     moveq    #$00,d5
  143.     bra.s    xxx_use
  144.  
  145. data_use
  146.     moveq    #$04,d5
  147.     bra.s    xxx_use
  148.  
  149. dest_use
  150.     moveq    #$08,d5
  151.     bra.s    xxx_use
  152.  
  153. spl_use
  154.     move.w    #$88,d5
  155.  
  156. xxx_use
  157.     bsr.l    ut_stos        ; get a string
  158.     bne.s    xxx_rts        ; ... oops
  159.     cmp.w    #30,0(a6,a1.l)    ; <=30 characters long
  160.     bgt    mdv_bp        ; ... oops
  161.  
  162.     moveq    #MT.INF,d0    ; find the system variables
  163.     trap    #1
  164.     lea    SV_PROGD(a0),a0    ; and set the pointers to
  165.                 ; the defaults
  166.     move.w    d5,d0
  167.     andi.b    #$7F,d0
  168.     move.l    0(a0,d0.w),a4
  169.  
  170.     move.w    0(a6,a1.l),d1
  171.     addq.l    #2,a1
  172.     move.w    d1,(a4)+
  173.  
  174.     tst.b    d5
  175.     bmi.s    xxx_dec
  176.  
  177.     lea    -1(a1,d1.w),a2
  178.     cmpi.b    #'_',0(a6,a2.l)
  179.  
  180.     beq.s    xxx_dec
  181.  
  182.     cmpi.w    #30,d1
  183.     beq    mdv_bp        ; name too long
  184.  
  185.     move.b    #'_',0(a4,d1.w)    ; append underline
  186.  
  187.     addq.w    #1,d1
  188.     move.w    d1,-2(a4)    ; increment length
  189.     subq.w    #1,d1
  190.  
  191.     bra.s    xxx_dec
  192.  
  193. xxx_lup
  194.     move.b    0(a6,a1.l),d0
  195.     addq.l    #1,a1
  196.     move.b    d0,(a4)+
  197.  
  198. xxx_dec
  199.     dbra    d1,xxx_lup
  200.  
  201.     moveq    #0,d0
  202.  
  203. xxx_rts
  204.     rts
  205.  
  206. prog_d$
  207.     moveq    #0,d5
  208.     bra.s    xxx_d$
  209.  
  210. data_d$
  211.     moveq    #4,d5
  212.     bra.s    xxx_d$
  213.  
  214. dest_d$
  215.     moveq    #8,d5
  216.     bra.s    xxx_d$
  217.  
  218. spl_d$
  219.     moveq    #8,d5
  220.  
  221. xxx_d$
  222.     cmp.l    a3,a5
  223.     bne    mdv_bp        ; ... oops
  224.  
  225.     moveq    #MT.INF,d0    ; find the system variables
  226.     trap    #1
  227.     lea    SV_PROGD(a0),a0    ; and set the pointers to
  228.                 ; the defaults
  229.     move.l    0(a0,d5),a4
  230.  
  231.     move.w    (a4)+,d4
  232.  
  233.     move.l    d4,d1
  234.     addq.l    #1,d1
  235.     and.b    #$FE,d1
  236.     move.w    BV.CHRIX,a2
  237.     jsr    (a2)
  238.  
  239.     sub.l    d1,BV_RIP(a6)
  240.     move.l    BV_RIP(a6),a1
  241.  
  242.     move.w    d4,0(a6,a1.l)
  243.     addq.l    #2,a1
  244.     bra.s    xxx_dec$
  245.  
  246. xxx_lup$
  247.     move.b    (a4)+,d0
  248.     move.b    d0,0(a6,a1.l)
  249.     addq.l    #1,a1
  250.  
  251. xxx_dec$
  252.     dbra    d4,xxx_lup$
  253.  
  254.     move.l    BV_RIP(a6),a1
  255.     moveq    #1,d4
  256.     moveq    #0,d0
  257.     rts
  258.  
  259. ; Set the name of the microdrive system
  260.  
  261. mdv_use
  262.     lea    md_io(pc),a4    ; Get entry point for io
  263.                 ; routines
  264. dev_use
  265.     bsr.l    ut_stos        ; get a string
  266.     bne.s    mdv_rts        ; ... oops
  267.     subq.w    #3,0(a6,a1.l)    ; 3 characters long
  268.     bne.s    mdv_bp        ; ... oops
  269.     move.l    2(a6,a1.l),d6    ; get new name
  270.     and.l    #$5f5f5f00,d6    ; in upper case
  271.     add.b    #'0',d6        ; ending with '0'
  272.  
  273.     moveq    #MT.INF,d0    ; find system vars
  274.     trap    #1
  275.     move.l    SV_DDLST(a0),a0    ; ... and linked list of
  276.                 ; directory drivers
  277.  
  278. mdv_look
  279.     cmp.l    SV_AIO-SV_LIO(a0),a4 ; the right driver?
  280.     beq.s    mdv_set        ; ... yes
  281.     move.l    (a0),a0        ; ... no, try the next
  282.     move.l    a0,d1        ; ... the last?
  283.     bne.s    mdv_look
  284. mdv_bp
  285.     moveq    #ERR.BP,d0
  286. mdv_rts
  287.     rts
  288. mdv_set
  289.     move.l    d6,CH_DRNAM(a0)    ; set new name
  290.     rts
  291.  
  292. ; --------------------------------------------------------------
  293. ; Get a string on the stack V0.2  1985 Tony Tebby QJUMP
  294. ; Modified to accept numbers and expressions
  295. ; (C) 1986 David Oliver CST V 4.00
  296.  
  297. ut_stos
  298.     tst.w    2(a6,a3.l)    ; Get name of parameter. If
  299.                 ; none, it must be exprssn.
  300.     bmi.s    get_string    ; ... so convert the value
  301.                 ; to a string.  ** 4.00 **
  302.     moveq    #$0f,d0        ; extract type of parameter.
  303.     and.b    1(a6,a3.l),d0
  304.     subq.b    #1,d0        ; is it a string?
  305.     bne.s    ut_gtnam     ; ... no, get the name
  306.                 ; instead
  307. get_string
  308.     move.l    a5,-(sp)     ; ... yes, save the top
  309.                 ; pointer
  310.     lea    8(a3),a5     ; get just one string
  311.     move.w    CA.GTSTR,a2
  312.     jsr    (a2)
  313.     move.l    (sp)+,a5     ; restore top pointer
  314.     bne.s    utils_rts
  315.     moveq    #3,d1        ; get total length of string
  316.     add.w    0(a6,a1.l),d1
  317.     bclr    #0,d1
  318.     add.l    d1,BV_RIP(a6)    ; and reset ri stack pointer
  319.     bra.s    utils_ok
  320. ut_gtnam
  321.     moveq    #ERR.BP,d0    ; assume bad parameter
  322.     moveq    #0,d1
  323.     move.w    2(a6,a3.l),d1    ; get the pointer to the
  324.                 ; real entry
  325.     bmi.s    utils_rts    ; ... expression is no good
  326.     lsl.l    #3,d1        ; in multiples of 8 bytes
  327.     add.l    BV_NTBAS(a6),d1
  328. ut_ntnam
  329.     moveq    #0,d6
  330.     move.w    2(a6,d1.l),d6    ; thus the pointer to the
  331.                 ; name
  332.     add.l    BV_NLBAS(a6),d6
  333.     moveq    #0,d1        ; get the length of the name
  334.                 ; as a long word
  335.     move.b    0(a6,d6.l),d1
  336.     addq.l    #1,d1        ; rounded up
  337.     bclr    #0,d1
  338.     move.w    d1,d4        ; and save it
  339.     addq.l    #2,d1        ; space required is +2 bytes
  340.     move.w    BV.CHRIX,a2    ; on ri stack
  341.     jsr    (a2)
  342.     move.l    BV_RIP(a6),a1
  343.  
  344.     add.w    d4,d6        ; move to end of string
  345.                 ; (ish)
  346. ut_nam_loop
  347.     subq.l    #1,a1        ; and copy one byte at a
  348.                 ; time
  349.     move.b    0(a6,d6.l),0(a6,a1.l)
  350.     subq.l    #1,d6
  351.     dbra    d4,ut_nam_loop    ; including the (byte) name
  352.                 ; length
  353.     subq.l    #1,a1        ; put a zero on to make it a
  354.                 ; word
  355.     clr.b    0(a6,a1.l)
  356. utils_ok
  357.     moveq    #0,d0
  358. utils_rts
  359.     rts
  360.  
  361.     END
  362. ; --------------------------------------------------------------
  363. */endfile
  364.